package com.ls.smartcampus2.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ls.smartcampus2.pojo.TreeHole;
import com.ls.smartcampus2.service.TreeHoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author dell
 */
@RestController
public class TreeHoleController {
    @Autowired
    private TreeHoleService treeHoleService;
    @GetMapping("/addTreeHoleMsg")
    public String addTreeHoleMsg(int msgId,String sid,String msgText){
        treeHoleService.addTreeHoleMsg(msgId,sid,msgText);
        return "插入数据成功";
    }
@GetMapping("/addTreeHoleImg")
    public String addTreeHoleImg(int msgId,String sid,String imgUrl){
        treeHoleService.addTreeHoleImg(msgId,sid,imgUrl);
        return "插入图片成功";
    }

@GetMapping("/queryMsgIdBySid")
    public String queryMsgIdBySid(String sid){
        //msgId 从数据库查询最新的一次信息id
        int msgId = treeHoleService.queryMsgIdBySid(sid);
             msgId+=1;
         return String.valueOf(msgId);
    }


}
